(deftemplate scenariu (slot persoana) (slot actiune) (slot p_locatie) (slot locatie) (slot ora1) (slot min1) (slot ora2) (slot min2))
(defglobal ?*data* = (new java.util.Date))
(defglobal ?*rand* = (new java.util.Random))
(deftemplate intrare (slot val))
(defglobal ?*dataJohn* = (new java.util.Date))

(defglobal ?*oraJohn* = 1)
(defglobal ?*minJohn* = 1)
(deffunction ia_ora_John ()
(return (call ?*dataJohn* getHours )))
(deffunction ia_min_John ()
(return (call ?*dataJohn* getMinutes )))
(deffunction seteaza_ora_John (?x)
(call ?*dataJohn* setHours ))
(deffunction seteaza_min_John (?x)
(call ?*dataJohn* setMinutes ))
(deffunction schimba_ora_John (?*minJohn*)
(call ?*dataJohn* setMinutes(+ ?*minJohn* (ia_min_John))))
(defglobal ?*dataMary* = (new java.util.Date))

(defglobal ?*oraMary* = 1)
(defglobal ?*minMary* = 1)
(deffunction ia_ora_Mary ()
(return (call ?*dataMary* getHours )))
(deffunction ia_min_Mary ()
(return (call ?*dataMary* getMinutes )))
(deffunction seteaza_ora_Mary (?x)
(call ?*dataMary* setHours ))
(deffunction seteaza_min_Mary (?x)
(call ?*dataMary* setMinutes ))
(deffunction schimba_ora_Mary (?*minMary*)
(call ?*dataMary* setMinutes(+ ?*minMary* (ia_min_Mary))))
(defglobal ?*dataGeorge* = (new java.util.Date))

(defglobal ?*oraGeorge* = 1)
(defglobal ?*minGeorge* = 1)
(deffunction ia_ora_George ()
(return (call ?*dataGeorge* getHours )))
(deffunction ia_min_George ()
(return (call ?*dataGeorge* getMinutes )))
(deffunction seteaza_ora_George (?x)
(call ?*dataGeorge* setHours ))
(deffunction seteaza_min_George (?x)
(call ?*dataGeorge* setMinutes ))
(deffunction schimba_ora_George (?*minGeorge*)
(call ?*dataGeorge* setMinutes(+ ?*minGeorge* (ia_min_George))))

(defrule enterstheBathroom_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "enters the Bathroom")))
(schimba_ora_John 1)
(printout t "John enters the Bathroom at "x":"t)) 

(defrule exitstheBathroom_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "exits the Bathroom")))
(schimba_ora_John 1)
(printout t "John exits the Bathroom at "x":"t)) 

(defrule enterstheKitchen_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "enters the Kitchen")))
(schimba_ora_John 1)
(printout t "John enters the Kitchen at "x":"t)) 

(defrule exitstheKitchen_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "exits the Kitchen")))
(schimba_ora_John 1)
(printout t "John exits the Kitchen at "x":"t)) 

(defrule enterstheBedroom_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "enters the Bedroom")))
(schimba_ora_John 1)
(printout t "John enters the Bedroom at "x":"t)) 

(defrule exitstheBedroom_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "exits the Bedroom")))
(schimba_ora_John 1)
(printout t "John exits the Bedroom at "x":"t)) 

(defrule wakesup_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "wakes up")))
(schimba_ora_John 1)
(printout t "John wakes up at "x":"t)) 

(defrule goes_John
(declare (salience 50))
(test(eq ?*oraJohn* 22))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "goes")))
(schimba_ora_John 1)
(printout t "John goes at "x":"t)) 

(defrule enterstheBathroom_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "enters the Bathroom")))
(schimba_ora_Mary 1)
(printout t "Mary enters the Bathroom at "x":"t)) 

(defrule exitstheBathroom_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "exits the Bathroom")))
(schimba_ora_Mary 1)
(printout t "Mary exits the Bathroom at "x":"t)) 

(defrule enterstheKitchen_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "enters the Kitchen")))
(schimba_ora_Mary 1)
(printout t "Mary enters the Kitchen at "x":"t)) 

(defrule exitstheKitchen_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "exits the Kitchen")))
(schimba_ora_Mary 1)
(printout t "Mary exits the Kitchen at "x":"t)) 

(defrule enterstheBedroom_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "enters the Bedroom")))
(schimba_ora_Mary 1)
(printout t "Mary enters the Bedroom at "x":"t)) 

(defrule exitstheBedroom_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "exits the Bedroom")))
(schimba_ora_Mary 1)
(printout t "Mary exits the Bedroom at "x":"t)) 

(defrule wakesup_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "wakes up")))
(schimba_ora_Mary 1)
(printout t "Mary wakes up at "x":"t)) 

(defrule goes_Mary
(declare (salience 50))
(test(eq ?*oraMary* 22))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "goes")))
(schimba_ora_Mary 1)
(printout t "Mary goes at "x":"t)) 

(defrule enterstheBathroom_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "enters the Bathroom")))
(schimba_ora_George 1)
(printout t "George enters the Bathroom at "x":"t)) 

(defrule exitstheBathroom_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "exits the Bathroom")))
(schimba_ora_George 1)
(printout t "George exits the Bathroom at "x":"t)) 

(defrule enterstheKitchen_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "enters the Kitchen")))
(schimba_ora_George 1)
(printout t "George enters the Kitchen at "x":"t)) 

(defrule exitstheKitchen_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "exits the Kitchen")))
(schimba_ora_George 1)
(printout t "George exits the Kitchen at "x":"t)) 

(defrule enterstheBedroom_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "enters the Bedroom")))
(schimba_ora_George 1)
(printout t "George enters the Bedroom at "x":"t)) 

(defrule exitstheBedroom_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "exits the Bedroom")))
(schimba_ora_George 1)
(printout t "George exits the Bedroom at "x":"t)) 

(defrule wakesup_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "wakes up")))
(schimba_ora_George 1)
(printout t "George wakes up at "x":"t)) 

(defrule goes_George
(declare (salience 50))
(test(eq ?*oraGeorge* 22))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "goes")))
(schimba_ora_George 1)
(printout t "George goes at "x":"t)) 

(defrule turnseverythingoff_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "turns everything off")))
(schimba_ora_John 1)
(printout t "John turns everything off at "x":"t)) 

(defrule openswindow_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "opens window")))
(schimba_ora_John 1)
(printout t "John opens window at "x":"t)) 

(defrule closeswindow_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "closes window")))
(schimba_ora_John 1)
(printout t "John closes window at "x":"t)) 

(defrule leaves_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "leaves")))
(schimba_ora_John 360)
(printout t "John leaves at "x":"t)) 

(defrule comeshome_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "comes home")))
(schimba_ora_John 1)
(printout t "John comes home at "x":"t)) 

(defrule drinks_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "drinks")))
(schimba_ora_John 1)
(printout t "John drinks at "x":"t)) 

(defrule isresting_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "is resting")))
(schimba_ora_John 46)
(printout t "John is resting from" x":"t"to" y":"v)) 

(defrule takesabath_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "takes a bath")))
(schimba_ora_John 55)
(printout t "John takes a bath from" x":"t"to" y":"v)) 

(defrule showers_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "showers")))
(schimba_ora_John 20)
(printout t "John showers from" x":"t"to" y":"v)) 

(defrule eats_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "eats")))
(schimba_ora_John 20)
(printout t "John eats from" x":"t"to" y":"v)) 

(defrule usesToilet_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "uses Toilet")))
(schimba_ora_John 5)
(printout t "John uses Toilet from" x":"t"to" y":"v)) 

(defrule usesSink_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "uses Sink")))
(schimba_ora_John 5)
(printout t "John uses Sink from" x":"t"to" y":"v)) 

(defrule turnsonTV_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "turns on TV")))
(schimba_ora_John 1)
(printout t "John turns on TV at "x":"t)) 

(defrule turnsonTheLight_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "turns on The Light")))
(schimba_ora_John 1)
(printout t "John turns on The Light at "x":"t)) 

(defrule turnsonStove_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "turns on Stove")))
(schimba_ora_John 1)
(printout t "John turns on Stove at "x":"t)) 

(defrule turnsoffTV_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "turns off TV")))
(schimba_ora_John 1)
(printout t "John turns off TV at "x":"t)) 

(defrule turnsoffTheLight_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "turns off The Light")))
(schimba_ora_John 1)
(printout t "John turns off The Light at "x":"t)) 

(defrule turnsoffStove_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "turns off Stove")))
(schimba_ora_John 1)
(printout t "John turns off Stove at "x":"t)) 

(defrule setsStoveLow_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "sets Stove Low")))
(schimba_ora_John 1)
(printout t "John sets Stove Low at "x":"t)) 

(defrule setsStoveMedium_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "sets Stove Medium")))
(schimba_ora_John 1)
(printout t "John sets Stove Medium at "x":"t)) 

(defrule setsStoveHigh_John
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "John") (actiune "sets Stove High")))
(schimba_ora_John 1)
(printout t "John sets Stove High at "x":"t)) 

(defrule turnseverythingoff_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "turns everything off")))
(schimba_ora_Mary 1)
(printout t "Mary turns everything off at "x":"t)) 

(defrule openswindow_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "opens window")))
(schimba_ora_Mary 1)
(printout t "Mary opens window at "x":"t)) 

(defrule closeswindow_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "closes window")))
(schimba_ora_Mary 1)
(printout t "Mary closes window at "x":"t)) 

(defrule leaves_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "leaves")))
(schimba_ora_Mary 360)
(printout t "Mary leaves at "x":"t)) 

(defrule comeshome_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "comes home")))
(schimba_ora_Mary 1)
(printout t "Mary comes home at "x":"t)) 

(defrule drinks_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "drinks")))
(schimba_ora_Mary 1)
(printout t "Mary drinks at "x":"t)) 

(defrule isresting_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "is resting")))
(schimba_ora_Mary 46)
(printout t "Mary is resting from" x":"t"to" y":"v)) 

(defrule takesabath_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "takes a bath")))
(schimba_ora_Mary 55)
(printout t "Mary takes a bath from" x":"t"to" y":"v)) 

(defrule showers_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "showers")))
(schimba_ora_Mary 20)
(printout t "Mary showers from" x":"t"to" y":"v)) 

(defrule eats_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "eats")))
(schimba_ora_Mary 20)
(printout t "Mary eats from" x":"t"to" y":"v)) 

(defrule usesToilet_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "uses Toilet")))
(schimba_ora_Mary 5)
(printout t "Mary uses Toilet from" x":"t"to" y":"v)) 

(defrule usesSink_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "uses Sink")))
(schimba_ora_Mary 5)
(printout t "Mary uses Sink from" x":"t"to" y":"v)) 

(defrule turnsonTV_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "turns on TV")))
(schimba_ora_Mary 1)
(printout t "Mary turns on TV at "x":"t)) 

(defrule turnsonTheLight_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "turns on The Light")))
(schimba_ora_Mary 1)
(printout t "Mary turns on The Light at "x":"t)) 

(defrule turnsonStove_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "turns on Stove")))
(schimba_ora_Mary 1)
(printout t "Mary turns on Stove at "x":"t)) 

(defrule turnsoffTV_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "turns off TV")))
(schimba_ora_Mary 1)
(printout t "Mary turns off TV at "x":"t)) 

(defrule turnsoffTheLight_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "turns off The Light")))
(schimba_ora_Mary 1)
(printout t "Mary turns off The Light at "x":"t)) 

(defrule turnsoffStove_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "turns off Stove")))
(schimba_ora_Mary 1)
(printout t "Mary turns off Stove at "x":"t)) 

(defrule setsStoveLow_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "sets Stove Low")))
(schimba_ora_Mary 1)
(printout t "Mary sets Stove Low at "x":"t)) 

(defrule setsStoveMedium_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "sets Stove Medium")))
(schimba_ora_Mary 1)
(printout t "Mary sets Stove Medium at "x":"t)) 

(defrule setsStoveHigh_Mary
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "Mary") (actiune "sets Stove High")))
(schimba_ora_Mary 1)
(printout t "Mary sets Stove High at "x":"t)) 

(defrule openswindow_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "opens window")))
(schimba_ora_George 1)
(printout t "George opens window at "x":"t)) 

(defrule closeswindow_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "closes window")))
(schimba_ora_George 1)
(printout t "George closes window at "x":"t)) 

(defrule leaves_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "leaves")))
(schimba_ora_George 360)
(printout t "George leaves at "x":"t)) 

(defrule comeshome_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "comes home")))
(schimba_ora_George 1)
(printout t "George comes home at "x":"t)) 

(defrule drinks_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "drinks")))
(schimba_ora_George 1)
(printout t "George drinks at "x":"t)) 

(defrule isresting_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "is resting")))
(schimba_ora_George 46)
(printout t "George is resting from" x":"t"to" y":"v)) 

(defrule takesabath_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "takes a bath")))
(schimba_ora_George 55)
(printout t "George takes a bath from" x":"t"to" y":"v)) 

(defrule showers_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "showers")))
(schimba_ora_George 20)
(printout t "George showers from" x":"t"to" y":"v)) 

(defrule eats_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "eats")))
(schimba_ora_George 20)
(printout t "George eats from" x":"t"to" y":"v)) 

(defrule usesToilet_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "uses Toilet")))
(schimba_ora_George 5)
(printout t "George uses Toilet from" x":"t"to" y":"v)) 

(defrule usesSink_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "uses Sink")))
(schimba_ora_George 5)
(printout t "George uses Sink from" x":"t"to" y":"v)) 

(defrule turnsonTV_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "turns on TV")))
(schimba_ora_George 1)
(printout t "George turns on TV at "x":"t)) 

(defrule turnsonTheLight_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "turns on The Light")))
(schimba_ora_George 1)
(printout t "George turns on The Light at "x":"t)) 

(defrule turnsoffTV_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "turns off TV")))
(schimba_ora_George 1)
(printout t "George turns off TV at "x":"t)) 

(defrule turnsoffTheLight_George
(declare (salience 50))
?id<-(intrare (val 0))
=>(assert(scenariu (persoana "George") (actiune "turns off The Light")))
(schimba_ora_George 1)
(printout t "George turns off The Light at "x":"t)) 

(facts)(run)